package com.java.action;

import java.util.List;

import com.java.pojo.ComEmp;
import com.java.service.IEmpService;

public class EmpAction {
	private static final int PAGEROW = 5;
	private IEmpService empservice;
	private List<ComEmp> emplist;

	private int page;
	private int currentPage;
	private int totalPages;

	public String execute() {
		System.out.println("execute.....");
		int rowCount = empservice.getEmpNum();
		System.out.println("rowCount:" + rowCount);
		totalPages = (rowCount % PAGEROW == 0) ? (rowCount / PAGEROW)
				: (rowCount / PAGEROW + 1);
		if (page < 1) {
			page = 1;
		}
		if (page > totalPages) {
			page = totalPages;
		}
		int start = (page - 1) * PAGEROW;
		currentPage = page;
		emplist = empservice.getEmpListByPage(start, PAGEROW);
		return "success";
	}
	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public static int getPagerow() {
		return PAGEROW;
	}

	public List<ComEmp> getEmplist() {
		return emplist;
	}

	public void setEmplist(List<ComEmp> emplist) {
		this.emplist = emplist;
	}

	public IEmpService getEmpservice() {
		return empservice;
	}

	public void setEmpservice(IEmpService empservice) {
		this.empservice = empservice;
	}



}
